mod nalgebra;
mod direct;
mod iteration;
mod gcr;

use nalgebra::solve_by_nalgebra;
use direct::solve_by_direct;
use iteration::IterationMethod;
use gcr::solve_by_gcr;

use ndarray::{Array1, Array2};

#[allow(unused)]
pub enum Solver {
    Nalgebra,
    Direct,
    Iteration(IterationMethod),
    GCR { tol: f64, max_iter: usize },
}

impl Solver {
    pub fn solve(self, x: Array2<f64>, y: Array1<f64>) -> Array1<f64> {
        match self {
            Solver::Nalgebra => solve_by_nalgebra(x, y),
            Solver::Direct  => solve_by_direct(x, y),
            Solver::Iteration(method) => method.solve(x, y),
            Solver::GCR { tol, max_iter }=> solve_by_gcr(x, y, tol, max_iter),
        }
    }
}
